//
//  HKUIKitViewController.m
//  HKiOSTools
//
//  Created by 胡锦涛 on 2020/12/22.
//

#import "HKUIKitViewController.h"
#import <objc/runtime.h>
#import "CommonBundle.h"
// 架构框架
#import "BifrostHeader.h"
#import "UIKitModuleService.h"
// 实例
#import "HKThemeViewController.h"
#import "HKConsoleViewController.h"
#import "HKNavigationListViewController.h"
#import "HKOrientationViewController.h"
#import "HKPrefixHeader.h"
#import "HKModelMap.h"
#import "HKModelUser.h"
@interface HKUIKitViewController ()

@end

@implementation HKUIKitViewController
+ (void)load {
    [Bifrost bindURL:kRouteUIKitPage
           toHandler:^id _Nullable(NSDictionary * _Nullable parameters) {
        return [HKUIKitViewController new];
    }];
}
- (void)initDataSource {
    self.dataSource = [[QMUIOrderedDictionary alloc] initWithKeysAndObjects:
                       @"QMUITheme", [CommonBundle imageNamed:@"icon_grid_button"],
                       @"QMUIConsole", [CommonBundle imageNamed:@"icon_grid_label"],
                       @"QMUINavigationController", [CommonBundle imageNamed:@"icon_grid_navigation"],
                       @"ViewController Orientation", [CommonBundle imageNamed:@"icon_grid_orientation"],
                       @"QMUITextView", [CommonBundle imageNamed:@"icon_grid_textView"],
                       nil];
//
//    @"QMUITextField", UIImageMake(@"icon_grid_textField"),
//    @"QMUISlider", UIImageMake(@"icon_grid_slider"),
//    @"QMUIAlertController", UIImageMake(@"icon_grid_alert"),
//    @"QMUITableView", UIImageMake(@"icon_grid_cell"),
//
//    @"QMUINavigationController", UIImageMake(@"icon_grid_navigation"),
//    @"UISearchBar+QMUI", UIImageMake(@"icon_grid_search"),
//    @"UITabBarItem+QMUI", UIImageMake(@"icon_grid_tabBarItem"),
//    @"UIColor+QMUI", UIImageMake(@"icon_grid_color"),
//    @"UIImage+QMUI", UIImageMake(@"icon_grid_image"),
//    @"UIImageView+QMUI", UIImageMake(@"icon_grid_imageView"),
//    @"UIFont+QMUI", UIImageMake(@"icon_grid_font"),
//    @"UIControl+QMUI", UIImageMake(@"icon_grid_control"),
//    @"UIView+QMUI", UIImageMake(@"icon_grid_view"),
//    @"NSObject+QMUI", UIImageMake(@"icon_grid_nsobject"),
//    @"CAAnimation+QMUI", UIImageMake(@"icon_grid_caanimation"),
}

- (void)setupNavigationItems {
    [super setupNavigationItems];
    self.title = @"QMUIKit";
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem qmui_itemWithImage:UIImageMake(@"icon_nav_about") target:self action:@selector(handleAboutItemEvent)];
    AddAccessibilityLabel(self.navigationItem.rightBarButtonItem, @"打开关于界面");
}

- (void)didSelectCellWithTitle:(NSString *)title {
    UIViewController *viewController = nil;
    if ([title isEqualToString:@"QMUITheme"])
    {
        viewController = [[HKThemeViewController alloc] init];
    }else if ([title isEqualToString:@"QMUIConsole"])
    {
        viewController = [[HKConsoleViewController alloc] init];
    }else if ([title isEqualToString:@"QMUINavigationController"]) {
        viewController = [[HKNavigationListViewController alloc] init];
    }else if ([title isEqualToString:@"ViewController Orientation"]){
        viewController = [[HKOrientationViewController alloc] init];
    }
    if (viewController != nil) {
        viewController.title = title;
//        viewController.modalPresentationStyle = UIModalPresentationFullScreen;
//        [self.navigationController presentViewController:viewController animated:YES completion:nil];
        [self.navigationController pushViewController:viewController animated:YES];
    }else {
        [self hk_showMessage:@"暂未开发，敬请期待~"];
    }
    
}

- (void)handleAboutItemEvent {
    QMUIThemeManagerCenter.defaultThemeManager.currentThemeIdentifier = HKThemeIdentifierGrapefruit;
}

@end
